<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty highlight modifier plugin
 * author: allan@tudou.com 
 * date: 20070323
 * Type:     modifier<br>
 * Name:     highlight<br>
 * Purpose:  
 */
function smarty_modifier_highlight($sString, $rReplace, $sPrefix, $sPostfix)
{
    if (!$rReplace) {
        return $sString;
	}
	if (!is_array($rReplace)) {
		$rReplace = array($rReplace);
	}
    $r = array();
	$rReplacedata = array_unique($rReplace);
    foreach ((array)$rReplacedata as $s) {
        if (strlen($s)) {
            $r[$s] = str_replace("keyword",$s,$sPrefix).$s.$sPostfix;
        }
    }
    return strtr($sString, $r);
}
?>
